import {IsArray, IsNotEmpty, IsNumber, IsString, ValidateNested} from "class-validator";
import {Type} from "class-transformer";

import {ApiProperty} from "@nestjs/swagger";
import {CreateOptionDto} from "../dto/CreateOptionDto";

export class CreateQuestionDto {
  @IsNumber()
  id: number

  @ApiProperty({example: '', description: '问题内容'})
  @IsString()
  @IsNotEmpty()
  questionText: string;

  @ApiProperty({example: '', description: '问题类型'})
  @IsString()
  @IsNotEmpty()
  questionType: string


  question: CreateQuestionDto;

  @ApiProperty({type: () => [CreateOptionDto], description: '问题选项'})
  @IsArray()
  @ValidateNested({each: true})
  @Type(() => CreateOptionDto)
  options: CreateOptionDto[];

}
